home *** CD-ROM | disk | FTP | other *** search
- // -[Keep_Heading]-
-
-
- // -[Copyright_Mesg]-
- // --------------------------------------------------------------- //
- // (c) Copyright 1993-1994. Step Ahead Software Pty Limited. All rights reserved.
- // Class Source Filename: SQUARE.cpp
- // Description:
- // Implements a square object. Uses the Rectangle function.
- // --------------------------------------------------------------- //
-
-
- #include "SQUARE.h"
-
-
- // -[Keep_cpp_Extras]-
-
-
- // -[Module_Function_Decs]-
-
-
- // -[Module_Data_Decs_Def]-
-
-
- // -[Global_Data_Defs]-
-
-
- // -[Static_Member_Data_Defs]-
-
-
- // -[Function_Defs]-
-
- // Returns a hash value
- hashValueType
- Square::hashValue() const
- {
- return 0;
- }
-
- // Tests Equality
- int
- Square::isEqual(const Object& testObject) const
- {
- return FALSE;
- }
-
- // Unique class ID
- classType
- Square::isA() const
- {
- return SquareClass;
- }
-
- void
- Square::write(Ropstream os)
- {
- // Call to base class write functions
- os << SideLength;
- }
-
- Pvoid
- Square::read(Ripstream is)
- {
- // Call to base class read functions
- is >> SideLength;
- return this;
- }
-
- // Constructs the object before a stream input operation
- Square::Square(StreamableInit s)
- : Shape(s)
- {
- }
-
- // Output Class Info
- void
- Square::printOn(Rostream outputStream) const
- {
- }
-
- // Class Name
- char *
- Square::nameOf() const
- {
- return "Square";
- }
-
- // Constructs the square object with the given side length.
- Square::Square(int InitX, int InitY, int InitSide)
- : Shape(InitX, InitY)
- {
- Width = Height = SideLength = InitSide;
- Colour = RGB(255, 255, 0);
- }
-
- // Draws the square using the GDI function "Rectangle".
- void
- Square::Show(HDC hDC)
- {
- HBRUSH hBrush = CreateSolidBrush(Colour);
- HBRUSH hOldBrush;
-
- hOldBrush = SelectObject(hDC, hBrush);
-
- // Draw the square
- Rectangle(hDC, X, Y, X + SideLength, Y + SideLength);
-
- SelectObject(hDC, hOldBrush);
- DeleteObject(hBrush);
- }
-
- // -[Persistent]-
- // OWL 1.0 streamability
- PTStreamable Square::build()
- {
- return new Square(streamableInit);
- }
-
- const Pchar Square::streamableName() const
- {
- return "Square";
- }
-
- TStreamableClass RegSquare("Square", Square::build,
- __DELTA(Square));